import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '版本号',
    align: 'center',
    dataIndex: 'appVersion',
  },
  {
    title: '系统',
    align: 'center',
    dataIndex: 'appOs',
    customRender: ({ text }) => {
      return text == 'ANDROID' ? '安卓' : 'IOS';
    },
  },
  {
    title: '平台',
    align: 'center',
    dataIndex: 'platform_dictText',
  },
  {
    title: '更新方式',
    align: 'center',
    dataIndex: 'isForceUpdate',
    customRender: ({ text }) => {
      return text ? '强制更新' : '普通更新';
    },
  },
  {
    title: '发布状态',
    align: 'center',
    dataIndex: 'releaseStatus',
    customRender: ({ text }) => {
      return text ? '已发布' : '待发布';
    },
  },
  {
    title: '发布日期',
    align: 'center',
    dataIndex: 'releaseTime',
    // customRender: ({ text }) => {
    //   return !text ? '' : text.length > 10 ? text.substr(0, 10) : text;
    // },
  },
  {
    title: '安装包地址',
    align: 'center',
    dataIndex: 'versionUrl',
    // slots: { customRender: 'fileSlot' },
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '版本',
    field: 'appVersion',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '是否强制更新',
    field: 'isForceUpdate',
    component: 'JDictSelectTag',
    componentProps: {},
    colProps: { span: 6 },
  },
  {
    label: 'ANDROID/IOS',
    field: 'appOs',
    component: 'JDictSelectTag',
    componentProps: {},
    colProps: { span: 6 },
  },
  {
    label: '发布日期',
    field: 'releaseTime',
    component: 'RangePicker',
    colProps: { span: 6 },
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '版本',
    field: 'appVersion',
    component: 'Input',
  },
  {
    label: '版本下载地址',
    field: 'versionUrl',
    component: 'JUpload',
    componentProps: {},
  },
  {
    label: '是否强制更新',
    field: 'isForceUpdate',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: '',
    },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入是否强制更新!' }];
    },
  },
  {
    label: 'ANDROID/IOS',
    field: 'appOs',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: '',
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
